package com.dbz.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dbz.entity.Demand;
import com.dbz.service.DemandService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("demand")
@RestController
public class DemandController {
    @Resource
    private DemandService demandService;
@RequestMapping("selectPageAll")
    public Map selectPageAll(Integer page,Integer rows){
        Map<String,Object> map=new HashMap<>();
        QueryWrapper<Demand> queryWrapper =new QueryWrapper();
        IPage<Demand> pages=new Page<Demand>(page,rows);
        IPage<Demand> demandIPage=demandService.selectPage(pages,queryWrapper);
        map.put("rows",demandIPage.getRecords());
        map.put("total",demandIPage.getTotal());
        return map;
    }


    @RequestMapping("insertDemand")
    public int insertdemand(Demand demand){
    demandService.insertDemand(demand);
    return 1;
    }


    @RequestMapping("selectDemandList")
    public List<Demand> selectDemandList() {
        return demandService.selectDemandList();
    }


    @RequestMapping("updateDemandiskaidanByid")
    public int updateDemandiskaidanByid(String deid){
        demandService.updateDemandiskaidanByid(deid);
    return 1;
    }
}
